package com.example.whatrubbish.controller;

import com.example.whatrubbish.model.Integration;
import com.example.whatrubbish.service.IntegrationService;
import com.example.whatrubbish.utils.Constants;
import com.example.whatrubbish.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/integration")
public class IntegrationController {
    @Autowired
    IntegrationService integrationService;

    @GetMapping("/get")
    public JsonResult selectByUserId(@RequestParam(value = "userId", required = false) String userId) {
        return new JsonResult(Constants.STATUS_SUCCESS, "success", integrationService.selectByUserId(userId));
    }

    @PutMapping("/update")
    public JsonResult update(@RequestBody Integration integration) {
        return new JsonResult(Constants.STATUS_SUCCESS, "success", integrationService.update(integration));
    }
}
